package part_08_Wait_and_Notify;

import java.util.Scanner;

public class Processor {

	void produce() throws InterruptedException {

		synchronized (this) {
			System.out.println("Producer thread Started");
			wait();// can be called within sync code blocks only
			System.out.println("Producer thread resumed...");

		}

	}

	void consume() throws InterruptedException {
		Scanner scanner = new Scanner(System.in);
		Thread.sleep(2000);
		synchronized (this) {
			System.out.println("Waiting for you to press 'Enter'..");
			scanner.nextLine();

			System.out.println("'Enter' Key Pressed..");
			notify();// alike wait notify too can only be called within a
						// synchronised codeblock
 
			Thread.sleep(3000);
				
		}

	}

}
